package com.wyz.saas.common.utils

import java.util.*

object StringUtils{

    fun getRandomString(length: Int): String? {
        val random = Random()
        val sb = StringBuilder()
        for (i in 0 until length) {
            val number = random.nextInt(3) // 随机生产小于3的数
            var result: Long = 0
            when (number) {
                0 -> {
                    result = Math.round(Math.random() * 25 + 65)
                    sb.append(result.toChar())
                }
                1 -> {
                    result = Math.round(Math.random() * 25 + 97)
                    sb.append(result.toChar())
                }
                2 -> sb.append(Random().nextInt(10))
            }
        }
        return sb.toString()
    }

    fun getRandomNumber(length: Int): String? {
        val random = Random()
        val sb = java.lang.StringBuilder()
        for (i in 0 until length) {
            sb.append(random.nextInt(10))
        }
        return sb.toString()
    }
}